package cn.hchaojie.ssm.web;

import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginController {
	Logger logger = LoggerFactory.getLogger(LoginController.class);
	
	@RequestMapping("/pages/login")
	public String loing(@RequestParam("user") String user, 
			@RequestParam("password") String password,
			HttpSession session) {
		
		System.out.println("/pages/login");
		
		if ("admin".equals(user) && "admin".equals(password)) {
			session.setAttribute("user", user);
			logger.info("登陆成功！");

			
			// 跳到文件列表界面
			return "redirect:/posts/findPage";
		} else {
			logger.info("登陆失败！");
			// 重新跳到登陆界面
			return "login";
		}
	}
}
